package com.hellpro.lolbox.mine.view;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hellpro.lolbox.R;
import com.hellpro.lolbox.base.LolBaseActivity;
import com.hellpro.lolbox.mine.presenter.LoginPresenter;
import com.hellpro.lolbox.utils.ToastShowCenter;
import com.hellpro.lolbox.utils.UIManger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bmob.v3.Bmob;

public class LoginActivity extends LolBaseActivity implements ILoginActivity {


    @BindView(R.id.mine_login_iv_back)
    ImageView mineLoginIvBack;
    @BindView(R.id.mine_login_tv_register)
    TextView mineLoginTvRegister;
    @BindView(R.id.mine_login_et_userName)
    EditText mineLoginEtUserName;
    @BindView(R.id.mine_login_et_passWord)
    EditText mineLoginEtPassWord;
    @BindView(R.id.mine_login_btn_login)
    Button mineLoginBtnLogin;
    @BindView(R.id.mine_login_tv_forgetPassword)
    TextView mineLoginTvForgetPassword;
    @BindView(R.id.mine_login_tv_smsLogin)
    TextView mineLoginTvSmsLogin;
    @BindView(R.id.activity_login)
    RelativeLayout activityLogin;
    private LoginPresenter presenter;
    private SharedPreferences sp;

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public void initView() {
        Bmob.initialize(getApplicationContext(), "b9e80a06ccaa5632b74a3e3f12aedc9b");
        presenter = new LoginPresenter(this);
        sp = getSharedPreferences("isLogin", MODE_PRIVATE);
    }

    @Override
    public ImageView getIvBack() {
        return mineLoginIvBack;
    }

    @Override
    public TextView getTvRegister() {
        return mineLoginTvRegister;
    }

    @Override
    public EditText getEtUserName() {
        return mineLoginEtUserName;
    }

    @Override
    public EditText getEtPassWord() {
        return mineLoginEtPassWord;
    }

    @Override
    public Button getBtnLogin() {
        return mineLoginBtnLogin;
    }

    @Override
    public TextView getTvForgetPassWord() {
        return mineLoginTvForgetPassword;
    }

    @Override
    public TextView getTvMsmLogin() {
        return mineLoginTvSmsLogin;
    }

    @Override
    public Context getLoginContext() {
        return LoginActivity.this;
    }

    @Override
    public SharedPreferences getSP() {
        return sp;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.mine_login_iv_back, R.id.mine_login_tv_register, R.id.mine_login_et_userName, R.id.mine_login_et_passWord, R.id.mine_login_btn_login, R.id.mine_login_tv_forgetPassword, R.id.mine_login_tv_smsLogin})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.mine_login_iv_back:
                finish();
                break;
            case R.id.mine_login_tv_register:
                UIManger.startToActivity(LoginActivity.this, RegisterActivity.class);
                finish();
                break;
            case R.id.mine_login_et_userName:
                break;
            case R.id.mine_login_et_passWord:
                break;
            case R.id.mine_login_btn_login:
                presenter.setLoginInfo();
                finish();
                break;
            case R.id.mine_login_tv_forgetPassword:
                ToastShowCenter.centerToast(LoginActivity.this,"该功能正在完善");
                break;
            case R.id.mine_login_tv_smsLogin:
                UIManger.startToActivity(LoginActivity.this,PhoneSmsLoginActivity.class);
                break;
        }
    }


   /* @OnClick({R.id.mine_login_iv_back, R.id.mine_login_tv_register, R.id.mine_login_et_userName, R.id.mine_login_et_passWord, R.id.mine_login_btn_login, R.id.mine_login_tv_forgetPassword})
    public void onClick(View view) {
        switch (view.getId()) {
            //返回键处理
            case R.id.mine_login_iv_back:
                finish();
                break;
            //注册按钮的监听
            case R.id.mine_login_tv_register:
                UIManger.startToActivity(LoginActivity.this, RegisterActivity.class);
                break;
            //登录按钮点击后的监听
            case R.id.mine_login_btn_login:
                presenter.setLoginInfo();
                finish();
                break;
            //TODO：忘记密码的监听
            case R.id.mine_login_tv_forgetPassword:
                ToastShowCenter.centerToast(LoginActivity.this,"该功能正在完善");
                break;
            //TODO:短信验证码快速登录监听：
            case R.id.mine_login_tv_smsLogin:
                UIManger.startToActivity(LoginActivity.this,PhoneSmsLoginActivity.class);
                break;
        }
    }*/
}
